@extends('Admin.layout.layout')
@section('title','用户管理')
@section('con')


    <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                   
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                          <h2 class="page-header">修改用户资料</h2>
                        </div>
                        @if (count($errors) > 0)
                            <div class="alert alert-danger">
                                <ul>
                                    @foreach ($errors->all() as $error)
                                        <li>{{ $error }}</li>
                                    @endforeach
                                </ul>
                            </div>
                        @endif
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-6 col-lg-offset-3">
                                    <form role="form" id="myform" action="{{url('/Admin/user/update')}}" method="post" enctype="multipart/form-data">
                                       
                                        <div class="form-group">
                                            <label>用户名:</label>
                                            <input name="uname" value="{{$users->uname}}" class="form-control">
                                            <div id="nameinfo" style="display:none"></div>
                                        </div>


                                         <div class="form-group">
                                            <label>权限:</label>
                                            <input name="auth"  value="{{$users->auth}}" class="form-control">
                                            <div id="code" style="display:none"></div>
                                        </div>

                                        <div class="form-group">
                                            <label>邮箱:</label>
                                            <input name="email" value="{{$users->email}}" class="form-control">
                                            <div id="email" style="display:none"></div>
                                        </div>

                                        <div class="form-group">
                                            <label>手机号:</label>
                                            <input name="tel" value="{{$users->tel}}" class="form-control">
                                            <div id="mobile" style="display:none"></div>
                                        </div>
                                        <div class="form-group">
                                            <label>头像:</label>
                                            <input type="file" name="uface">
                                            <div id="email" style="display:none"></div>
                                        </div>
                                        <div class="form-group">                              
                                            <input type="hidden" name="uid" value="{{$users->uid}}">
                                        </div>
                                        {{csrf_field()}}
                                       
                                        <button class="btn btn-primary" type="submit">添加</button>
                                        <button class="btn btn-danger" type="reset">重置</button>
                                       
                                    </form>
                                </div>
                                <!-- /.col-lg-6 (nested) -->
                              
                                <!-- /.col-lg-6 (nested) -->
                            </div>
                            <!-- /.row (nested) -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
            </div>
        </div>
@endsection
@section('js')
           <script type="text/javascript">
            //获取表单对象
            var myform = document.getElementById('myform');
           
            //获取div元素
            var nameinfo = document.getElementById('nameinfo');
           
            var mobile = document.getElementById('mobile');
            var email = document.getElementById('email');
            var code = document.getElementById('code');

            //获取表单用户名丧失焦点事件
            myform.uname.onblur = function()
            {
              
                    //获取输入的内容
                    var v = this.value;
                    var reg = /^\w{6,18}$/;
                    if(reg.test(v)){
                    
                       nameinfo.style.display = 'none';
                       this.style.border = '#c6c6c6 1px solid'; 
                       CUSER = true;
                    }else{
                       
                       this.style.border = 'red 1px solid'; 
                       nameinfo.innerHTML = '输入的用户名不符合要求';
                       nameinfo.style.color = 'red';
                       nameinfo.style.display = 'block';
                        CUSER = false;
                    }
            }


        //绑定表单确认密码失去焦点事件
         myform.auth.onblur = function()
        {
                 //获取输入的内容
                var v = this.value;
                var reg = /^[012]$/;
                if(reg.test(v)){
                   code.style.display = 'none';
                   this.style.border = '#c6c6c6 1px solid'; 
                   CPHONE = true;
                }else{
                   this.style.border = 'red 1px solid'; 
                   code.innerHTML = '输入的权限值不符合要求';
                   code.style.color = 'red';
                   code.style.display = 'block';
                   CPHONR = false;
                }
               
        }

        //绑定表单手机号的失去焦点事件
        myform.tel.onblur = function()
        {
          
                //获取输入的内容
                var v = this.value;
                var reg = /^1[34578]\d{9}$/;
                if(reg.test(v)){
                   mobile.style.display = 'none';
                   this.style.border = '#c6c6c6 1px solid'; 
                   CPHONE = true;
                }else{
                   this.style.border = 'red 1px solid'; 
                   mobile.innerHTML = '输入的手机号不符合要求';
                   mobile.style.color = 'red';
                   mobile.style.display = 'block';
                   CPHONR = false;
                }
        }

        //绑定表单邮箱的失去焦点事件
        myform.email.onblur = function()
        {
          
                //获取输入的内容
                var v = this.value;
                var reg = /^\w+@\w+\.(com|cn|com\.cn|net)$/;
                if(reg.test(v)){
                   email.style.display = 'none';
                   this.style.border = '#c6c6c6 1px solid'; 
                   CEMAIL = true;
                }else{
                   this.style.border = 'red 1px solid'; 
                   email.innerHTML = '输入的邮箱不符合要求';
                   email.style.color = 'red';
                   email.style.display = 'block';
                   CEMAIL = false;
                }
        }
           </script>
@endsection
            